package main

import (
	"flag"
	"log"
	"net"
	"net/http"
	"tym/codec"
	"tym/codec/internal/service"
)

var (
	port string
)

func main() {
	flag.StringVar(&port, "port", "8002", "config path, eg: -conf config.yaml")
	flag.Parse()

	listen, err := net.Listen("tcp", ":"+port)
	if err != nil {
		log.Fatal("rpc client: network error: ", err)
		return
	}
	log.Println("start rpc server on", listen.Addr())
	server := codec.Accept(listen)
	server.HandleHTTP()
	server.Register(new(service.Foo))

	http.Serve(listen, nil)
}
